<?php
class menus extends MY_Model{
    public function __construct() {
        parent::__construct();
    }
    //insert menu
    public function add_menu($fields=array()){   
        if(empty($fields)){
            return false;
        }
        $this->db->insert('menus',$fields);
        return $this->db->insert_id();
    }
   
    //get menu
    public function get_menu($conditions = array()){
        
        $query = $this->db->get_where('menus',$conditions);
        if($query->num_rows()===1){
            return $query->row();
        }
        return $query->result();
    }
    
    
    //update menu
    public function update_menu($field=array(),$conditions=array())
    {
        
            $this->db->update('menus',$field,$conditions);
            return $this->db->affected_rows();
        
    }
    
    //delete menu
    public function delete_menu($menu_id=false){
        if($menu_id){
            $this->db->where('menu_id',$menu_id);
            $this->db->delete('menus');
        }
        return $this->db->affected_rows();    
    }
    //Add menu type
    public function add_menu_type($fields=array())
    {
         if(empty($fields)){
            return false;
        }
        $this->db->insert('menu_type',$fields);
        return $this->db->insert_id();
    }
}
?>